package com.liwy3.order;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * Copyright © 元气森林（北京）食品科技集团有限公司. All rights reserved.
 *
 * @Description:
 * @author: Crazy4J
 * @date: 2022年02月24日 14:47
 * @version: V1.0
 * <p>
 * Feign的原理:
 * 1.首先会根据@EnableFeignClients => 扫描标记@FeignClient的接口, 然后创建接口名对应的FeignClientFactoryBean,  然后执行getObject方法 =>核心流程: 创建每个接口的代理类FeignInvocationHandler
 * 2.执行具体的feign调用时, 被具体接口的FeignInvocationHandler拦截, 组装请求参数,替换掉服务名为具体目标服务Ip. 利用Ribbon去调用具体的服务(http).
 *
 * seata的坑一: 分布式事务处理时,降级时会出现服务调用时无法回滚, 解决办法: 利用AOP切面处理service异常手动回滚事务解决
 * seata AT模式读未提交, 存在脏读
 *
 */
@SpringBootApplication
@EnableTransactionManagement(proxyTargetClass = true)
@EnableFeignClients(basePackages = {"com.liwy3"})
@EnableDiscoveryClient
@MapperScan("com.liwy3.order.mapper")
public class OrderApplication {
    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }
}
